package com.tianji.learning.controller.admin;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.entity.query.QuestionAdminPageQuery;
import com.tianji.learning.entity.vo.QuestionAdminVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/questions")
@Api(tags = "互动问答相关接口(管理端)")
@RequiredArgsConstructor
public class InteractionQuestionAdminController {

    private final IInteractionQuestionService questionService;

    @ApiOperation("分页查询问题列表-管理端")
    @GetMapping("page")
    public PageDTO<QuestionAdminVO> queryQuestionPageForAdmin(QuestionAdminPageQuery query) {
        return questionService.queryQuestionPageForAdmin(query);
    }


    @ApiOperation("查询问题详细信息")
    @GetMapping("{id}")
    public QuestionAdminVO queryQuestionDetail(@ApiParam(value = "问题id", example = "1") @PathVariable("id") Long id) {
        return questionService.queryQuestionDetail(id);
    }


    @ApiOperation("隐藏或显示问题")
    @PutMapping("{id}/hidden/{hidden}")
    public void hiddenQuestion(
            @ApiParam(value = "问题id", example = "1") @PathVariable("id") Long id,
            @ApiParam(value = "是否隐藏，true/false", example = "true") @PathVariable("hidden") Boolean hidden) {
        questionService.hiddenQuestion(id, hidden);
    }
}
